package com.example.jsoup.kuang.question;

import com.example.jsoup.kuang.question.utils.DetailPageUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by HMF on 2021/10/12 23:13
 */
public class MainTest {

    public static void main(String[] args) throws Exception {
        // type = 1
        String str1 = "/needs/detailthe?id=114541&type=1";
        String str2 = "/needs/detailthe?id=116519&type=1";
        String str3 = "/needs/detailthe?id=116513&type=1";

        // type = 2
//        String str1 = "/needs/detailThe?type=2&id=3202";
//        String str2 = "/needs/detailThe?type=2&id=3198";
//        String str3 = "/needs/detailThe?type=2&id=3192";

        List<String> urlList = new ArrayList<>();
        urlList.add(str1);
        urlList.add(str2);
        urlList.add(str3);

        for (int i = 0; i < urlList.size(); i++) {
            Map<String, String> pageData = DetailPageUtil.getPageData(urlList.get(i), 1);
            // 调用封装的方法返回爬取详情页的数据
//            Map<String, String> pageData = DetailPageUtil.getPageData(urlList.get(i), 2);

            System.out.println("\ntitle：\n" + pageData.get("need_name"));
            System.out.println("\ntime：\n" + pageData.get("public_time"));
            System.out.println("\nsource：\n" + pageData.get("source"));
            System.out.println("\nmoney：\n" + pageData.get("money"));

            System.out.println("\nindustry_category：\n" + pageData.get("industry_category"));
            System.out.println("\narea：\n" + pageData.get("area"));
            System.out.println("\ndemand_side：\n" + pageData.get("demand_side"));

            // type = 1
//            System.out.println("\nbackground_content：\n" + pageData.get("background_content"));
//            System.out.println("\nproblem_content：\n" + pageData.get("problem_content"));
//            System.out.println("\nbackground_content：\n" + pageData.get("background_content"));

            // type = 2
            System.out.println("\ndescribe_content：\n" + pageData.get("describe_content"));


            System.out.println();
            System.out.println();
            System.out.println();
        }

    }

}
